package com.leoman.dao;

import com.leoman.entity.Letter;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * LetterDao
 * Created by 涂奕恒 on 2016/11/23 0023 下午 3:43.
 */
public interface LetterDao extends JpaRepository<Letter, Integer>, JpaSpecificationExecutor<Letter> {

    @Query("select a from Letter a where a.user.id = ?1 and a.isDraft = 1")
    Letter iFindDraftByUserId(Integer userId);

    @Query("select a from Letter a where a.isDraft = 0 and a.isTop = 1")
    Letter iFindOneWithTop();
}